#if defined(_MSC_VER)
#pragma once
#endif

#ifndef LM_TEXTURE_UV_H
#define LM_TEXTURE_UV_H

#include "../core/lm.h"
#include "../core/spectrum.h"
#include "../core/texture.h"
#include "../core/intersection.h"

class UVTexture : public Texture<Spectrum> {
public:
	UVTexture(Reference<TextureMap> m) {
		mapping = m;
	}
	~UVTexture() {
		mapping = NULL;
	}
	Spectrum Evaluate(const Intersection &isect) const {
		float s, t;
		float zombie;
		mapping->Map(isect, &s, &t, &zombie, &zombie, &zombie, &zombie);
		float cs[COLOR_SAMPLES];
		memset(cs, 0, sizeof(cs));
		cs[0] = s - Floor2Int(s);
		cs[1] = t - Floor2Int(t);
		return Spectrum(cs);
	}
private:
	Reference<TextureMap> mapping;
};

#endif	// LM_TEXTURE_UV_H